<%-- 
    Document   : login
    Created on : May 18, 2011, 11:08:27 AM
    Author     : Lanjut
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
                    bean.Check_Bean log = (bean.Check_Bean) session.getAttribute("log");
                    String id = null;
                    if (log == null) {
                        log = new bean.Check_Bean();
                        session.setAttribute("log", log);
                    }
                    log.login();
                    int i;
                    for (i = 0; i < 100; i++) {
                        if (request.getParameter("name_admin").equalsIgnoreCase(log.getNameAdmin(i))) {
                            if (request.getParameter("password").equalsIgnoreCase(log.getPassword(i))) {
                                id = log.getId(i);
                                break;
                            }
                        }
                    }
                    if (i == 100) {
                        session.setAttribute("flag", "false");
                        response.sendRedirect("Error.jsp");
                    } else {
                        session.setAttribute("id_admin", id);
                        session.setAttribute("name_admin", request.getParameter("name_admin"));
                        session.setAttribute("password", request.getParameter("password"));
                        session.setAttribute("flag", "true");
                        //session.setAttribute("jabatan", log.getJabatan(i));
                        response.sendRedirect("admin.jsp");
                    }
        %>

    </body>
</html>
